1 /* 2 3 Boost Software License - Version 1.0 - August 17th, 2003 4 5 Permission is hereby granted, free of charge, to any person or organization 6 obtaining a copy of the software and accompanying documentation covered by 7 this license (the "Software") to use, reproduce, display, distribute, 8 execute, and transmit the Software, and to prepare derivative works of the 9 Software, and to permit third-parties to whom the Software is furnished to 10 do so, all subject to the following: 11 12 The copyright notices in the Software and this entire statement, including 13 the above license grant, this restriction and the following disclaimer, 14 must be included in all copies of the Software, in whole or in part, and 15 all derivative works of the Software, unless such copies or derivative 16 works are solely in the form of machine-executable object code generated by 17 a source language processor. 18 19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT 22 SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE 23 FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, 24 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 25 DEALINGS IN THE SOFTWARE. 26 27 */ 28 29 module derelict.glib.gdate; 30 31 import derelict.glib.gtypes; 32 import derelict.glib.glibconfig; 33 import core.stdc.config; 34 import core.stdc.time; 35 36 extern (C): 37 38 alias int GTime; 39 alias ushort GDateYear; 40 alias ubyte GDateDay; 41 alias _GDate GDate; 42 alias _Anonymous_0 GDateDMY; 43 alias _Anonymous_1 GDateWeekday; 44 alias _Anonymous_2 GDateMonth; 45 46 enum _Anonymous_0 47 { 48 G_DATE_DAY = 0, 49 G_DATE_MONTH = 1, 50 G_DATE_YEAR = 2 51 } 52 53 enum _Anonymous_1 54 { 55 G_DATE_BAD_WEEKDAY = 0, 56 G_DATE_MONDAY = 1, 57 G_DATE_TUESDAY = 2, 58 G_DATE_WEDNESDAY = 3, 59 G_DATE_THURSDAY = 4, 60 G_DATE_FRIDAY = 5, 61 G_DATE_SATURDAY = 6, 62 G_DATE_SUNDAY = 7 63 } 64 65 enum _Anonymous_2 66 { 67 G_DATE_BAD_MONTH = 0, 68 G_DATE_JANUARY = 1, 69 G_DATE_FEBRUARY = 2, 70 G_DATE_MARCH = 3, 71 G_DATE_APRIL = 4, 72 G_DATE_MAY = 5, 73 G_DATE_JUNE = 6, 74 G_DATE_JULY = 7, 75 G_DATE_AUGUST = 8, 76 G_DATE_SEPTEMBER = 9, 77 G_DATE_OCTOBER = 10, 78 G_DATE_NOVEMBER = 11, 79 G_DATE_DECEMBER = 12 80 } 81 82 struct _GDate 83 { 84 guint julian_days; 85 guint julian; 86 guint dmy; 87 guint day; 88 guint month; 89 guint year; 90 } 91 92 version(Derelict_Link_Static) 93 { 94 extern( C ) nothrow 95 { 96 GDate* g_date_new(); 97 GDate* g_date_new_dmy(GDateDay day, GDateMonth month, GDateYear year); 98 GDate* g_date_new_julian(guint32 julian_day); 99 void g_date_free(GDate* date); 100 gboolean g_date_valid(const(GDate)* date); 101 gboolean g_date_valid_day(GDateDay day); 102 gboolean g_date_valid_month(GDateMonth month); 103 gboolean g_date_valid_year(GDateYear year); 104 gboolean g_date_valid_weekday(GDateWeekday weekday); 105 gboolean g_date_valid_julian(guint32 julian_date); 106 gboolean g_date_valid_dmy(GDateDay day, GDateMonth month, GDateYear year); 107 GDateWeekday g_date_get_weekday(const(GDate)* date); 108 GDateMonth g_date_get_month(const(GDate)* date); 109 GDateYear g_date_get_year(const(GDate)* date); 110 GDateDay g_date_get_day(const(GDate)* date); 111 guint32 g_date_get_julian(const(GDate)* date); 112 guint g_date_get_day_of_year(const(GDate)* date); 113 guint g_date_get_monday_week_of_year(const(GDate)* date); 114 guint g_date_get_sunday_week_of_year(const(GDate)* date); 115 guint g_date_get_iso8601_week_of_year(const(GDate)* date); 116 void g_date_clear(GDate* date, guint n_dates); 117 void g_date_set_parse(GDate* date, const(gchar)* str); 118 void g_date_set_time_t(GDate* date, time_t timet); 119 void g_date_set_time_val(GDate* date, GTimeVal* timeval); 120 void g_date_set_time(GDate* date, GTime time_); 121 void g_date_set_month(GDate* date, GDateMonth month); 122 void g_date_set_day(GDate* date, GDateDay day); 123 void g_date_set_year(GDate* date, GDateYear year); 124 void g_date_set_dmy(GDate* date, GDateDay day, GDateMonth month, GDateYear y); 125 void g_date_set_julian(GDate* date, guint32 julian_date); 126 gboolean g_date_is_first_of_month(const(GDate)* date); 127 gboolean g_date_is_last_of_month(const(GDate)* date); 128 void g_date_add_days(GDate* date, guint n_days); 129 void g_date_subtract_days(GDate* date, guint n_days); 130 void g_date_add_months(GDate* date, guint n_months); 131 void g_date_subtract_months(GDate* date, guint n_months); 132 void g_date_add_years(GDate* date, guint n_years); 133 void g_date_subtract_years(GDate* date, guint n_years); 134 gboolean g_date_is_leap_year(GDateYear year); 135 guint8 g_date_get_days_in_month(GDateMonth month, GDateYear year); 136 guint8 g_date_get_monday_weeks_in_year(GDateYear year); 137 guint8 g_date_get_sunday_weeks_in_year(GDateYear year); 138 gint g_date_days_between(const(GDate)* date1, const(GDate)* date2); 139 gint g_date_compare(const(GDate)* lhs, const(GDate)* rhs); 140 void g_date_to_struct_tm(const(GDate)* date, tm* tm); 141 void g_date_clamp(GDate* date, const(GDate)* min_date, const(GDate)* max_date); 142 void g_date_order(GDate* date1, GDate* date2); 143 gsize g_date_strftime(gchar* s, gsize slen, const(gchar)* format, const(GDate)* date); 144 } 145 } 146 else 147 { 148 extern( C ) nothrow 149 { 150 alias da_g_date_new = GDate* function(); 151 alias da_g_date_new_dmy = GDate* function(GDateDay day, GDateMonth month, GDateYear year); 152 alias da_g_date_new_julian = GDate* function(guint32 julian_day); 153 alias da_g_date_free = void function(GDate* date); 154 alias da_g_date_valid = gboolean function(const(GDate)* date); 155 alias da_g_date_valid_day = gboolean function(GDateDay day); 156 alias da_g_date_valid_month = gboolean function(GDateMonth month); 157 alias da_g_date_valid_year = gboolean function(GDateYear year); 158 alias da_g_date_valid_weekday = gboolean function(GDateWeekday weekday); 159 alias da_g_date_valid_julian = gboolean function(guint32 julian_date); 160 alias da_g_date_valid_dmy = gboolean function(GDateDay day, GDateMonth month, GDateYear year); 161 alias da_g_date_get_weekday = GDateWeekday function(const(GDate)* date); 162 alias da_g_date_get_month = GDateMonth function(const(GDate)* date); 163 alias da_g_date_get_year = GDateYear function(const(GDate)* date); 164 alias da_g_date_get_day = GDateDay function(const(GDate)* date); 165 alias da_g_date_get_julian = guint32 function(const(GDate)* date); 166 alias da_g_date_get_day_of_year = guint function(const(GDate)* date); 167 alias da_g_date_get_monday_week_of_year = guint function(const(GDate)* date); 168 alias da_g_date_get_sunday_week_of_year = guint function(const(GDate)* date); 169 alias da_g_date_get_iso8601_week_of_year = guint function(const(GDate)* date); 170 alias da_g_date_clear = void function(GDate* date, guint n_dates); 171 alias da_g_date_set_parse = void function(GDate* date, const(gchar)* str); 172 alias da_g_date_set_time_t = void function(GDate* date, time_t timet); 173 alias da_g_date_set_time_val = void function(GDate* date, GTimeVal* timeval); 174 alias da_g_date_set_time = void function(GDate* date, GTime time_); 175 alias da_g_date_set_month = void function(GDate* date, GDateMonth month); 176 alias da_g_date_set_day = void function(GDate* date, GDateDay day); 177 alias da_g_date_set_year = void function(GDate* date, GDateYear year); 178 alias da_g_date_set_dmy = void function(GDate* date, GDateDay day, GDateMonth month, GDateYear y); 179 alias da_g_date_set_julian = void function(GDate* date, guint32 julian_date); 180 alias da_g_date_is_first_of_month = gboolean function(const(GDate)* date); 181 alias da_g_date_is_last_of_month = gboolean function(const(GDate)* date); 182 alias da_g_date_add_days = void function(GDate* date, guint n_days); 183 alias da_g_date_subtract_days = void function(GDate* date, guint n_days); 184 alias da_g_date_add_months = void function(GDate* date, guint n_months); 185 alias da_g_date_subtract_months = void function(GDate* date, guint n_months); 186 alias da_g_date_add_years = void function(GDate* date, guint n_years); 187 alias da_g_date_subtract_years = void function(GDate* date, guint n_years); 188 alias da_g_date_is_leap_year = gboolean function(GDateYear year); 189 alias da_g_date_get_days_in_month = guint8 function(GDateMonth month, GDateYear year); 190 alias da_g_date_get_monday_weeks_in_year = guint8 function(GDateYear year); 191 alias da_g_date_get_sunday_weeks_in_year = guint8 function(GDateYear year); 192 alias da_g_date_days_between = gint function(const(GDate)* date1, const(GDate)* date2); 193 alias da_g_date_compare = gint function(const(GDate)* lhs, const(GDate)* rhs); 194 alias da_g_date_to_struct_tm = void function(const(GDate)* date, tm* tm); 195 alias da_g_date_clamp = void function(GDate* date, const(GDate)* min_date, const(GDate)* max_date); 196 alias da_g_date_order = void function(GDate* date1, GDate* date2); 197 alias da_g_date_strftime = gsize function(gchar* s, gsize slen, const(gchar)* format, const(GDate)* date); 198 } 199 200 __gshared 201 { 202 da_g_date_new g_date_new; 203 da_g_date_new_dmy g_date_new_dmy; 204 da_g_date_new_julian g_date_new_julian; 205 da_g_date_free g_date_free; 206 da_g_date_valid g_date_valid; 207 da_g_date_valid_day g_date_valid_day; 208 da_g_date_valid_month g_date_valid_month; 209 da_g_date_valid_year g_date_valid_year; 210 da_g_date_valid_weekday g_date_valid_weekday; 211 da_g_date_valid_julian g_date_valid_julian; 212 da_g_date_valid_dmy g_date_valid_dmy; 213 da_g_date_get_weekday g_date_get_weekday; 214 da_g_date_get_month g_date_get_month; 215 da_g_date_get_year g_date_get_year; 216 da_g_date_get_day g_date_get_day; 217 da_g_date_get_julian g_date_get_julian; 218 da_g_date_get_day_of_year g_date_get_day_of_year; 219 da_g_date_get_monday_week_of_year g_date_get_monday_week_of_year; 220 da_g_date_get_sunday_week_of_year g_date_get_sunday_week_of_year; 221 da_g_date_get_iso8601_week_of_year g_date_get_iso8601_week_of_year; 222 da_g_date_clear g_date_clear; 223 da_g_date_set_parse g_date_set_parse; 224 da_g_date_set_time_t g_date_set_time_t; 225 da_g_date_set_time_val g_date_set_time_val; 226 da_g_date_set_time g_date_set_time; 227 da_g_date_set_month g_date_set_month; 228 da_g_date_set_day g_date_set_day; 229 da_g_date_set_year g_date_set_year; 230 da_g_date_set_dmy g_date_set_dmy; 231 da_g_date_set_julian g_date_set_julian; 232 da_g_date_is_first_of_month g_date_is_first_of_month; 233 da_g_date_is_last_of_month g_date_is_last_of_month; 234 da_g_date_add_days g_date_add_days; 235 da_g_date_subtract_days g_date_subtract_days; 236 da_g_date_add_months g_date_add_months; 237 da_g_date_subtract_months g_date_subtract_months; 238 da_g_date_add_years g_date_add_years; 239 da_g_date_subtract_years g_date_subtract_years; 240 da_g_date_is_leap_year g_date_is_leap_year; 241 da_g_date_get_days_in_month g_date_get_days_in_month; 242 da_g_date_get_monday_weeks_in_year g_date_get_monday_weeks_in_year; 243 da_g_date_get_sunday_weeks_in_year g_date_get_sunday_weeks_in_year; 244 da_g_date_days_between g_date_days_between; 245 da_g_date_compare g_date_compare; 246 da_g_date_to_struct_tm g_date_to_struct_tm; 247 da_g_date_clamp g_date_clamp; 248 da_g_date_order g_date_order; 249 da_g_date_strftime g_date_strftime; 250 } 251 }